<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>专业信息管理</title>
	<meta name="decorator" content="default"/>
    <link href="${ctxStatic}/bootstrap/plugins/chose/chosen.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="main-content">
    <tags:breadcrumb menuId="专业添加" />
    <div class="page-content">
        <form:form id="inputForm" modelAttribute="majorInfo" action="" method="post" class="form-horizontal">
            <form:hidden path="id"/>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">专业名称：</label>
                <div class="col-sm-3">
                    <form:input path="majorName" htmlEscape="false" maxlength="64" class="col-sm-10 required"/>
                    <span class="important">*</span>
                </div>
                <label class="col-sm-1 no-padding-right control-label">专业代码：</label>
                <div class="col-sm-3">
                    <form:input path="majorCode" htmlEscape="false" maxlength="20" class="col-sm-10 required"/>
                    <span class="important">*</span>
                </div>
                <label class="col-sm-1 no-padding-right control-label">专业层次：</label>
                <div class="col-sm-3">
                    <form:select path="majorLevel" class="col-sm-10 chosen-select required">
                        <form:option value="" label="--请选择--"/>
                        <form:options items="${fns:getDictList('zy_cc')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                    <span class="important">*</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">专业大类：</label>
                <div class="col-sm-3">
                    <form:select path="majorParentCode" cssClass="col-sm-10 required chosen-select">
                        <form:option value="" label="--请选择专业大类--"/>
                        <form:options items="${fns:getDictList('major_parent_code')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                    <span class="important">*</span>
                </div>
                <label class="col-sm-1 no-padding-right control-label">专业类别：</label>
                <div class="col-sm-3">
                    <form:select path="majorType" class="col-sm-10 required chosen-select">
                        <form:option value="" label="--请选择专业类别--"/>
                        <form:options items="${fns:getDictList('major_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                    <span class="important">*</span>
                </div>
                <label class="col-sm-1 no-padding-right control-label">修学年限：</label>
                <div class="col-sm-3">
                    <form:select path="studyLife" class="col-sm-10 required chosen-select">
                        <form:option value="" label="--请选择--"/>
                        <form:options items="${fns:getDictList('study_life')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                    <span class="important">*</span>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">授予学位：</label>
                <div class="col-sm-3">
                    <form:select path="awardDegree" class="col-sm-10 required chosen-select">
                        <form:option value="" label="--请选择--"/>
                        <form:options items="${fns:getDictList('award_degree')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
                    </form:select>
                    <span class="important">*</span>
                </div>
                <label class="col-sm-1 no-padding-right control-label">专业排名：</label>
                <div class="col-sm-3">
                    <form:input path="majorSort" htmlEscape="false" maxlength="11" class="col-sm-10 "/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">相近专业：</label>
                <div class="col-sm-10">
                    <form:hidden path="majorCloseNames" htmlEscape="false"/>
                    <select id="majorCloseCodes" name="majorCloseCodes" multiple="" class="width-80 chosen-select tag-input-style" data-placeholder="选择专业...">
                        <c:forEach items="${majorInfoList}" var="major">
                            <c:choose>
                                <c:when test="${fn:indexOf(majorInfo.majorCloseCodes,major.majorCode) >= 0}">
                                    <option value="${major.majorCode}" selected>${major.majorName}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${major.majorCode}">${major.majorName}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </select>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">专业解读：</label>
                <div class="col-sm-5">
                    <form:textarea path="majorDesc" cssClass="col-sm-10" rows="4"/>
                </div>
                <label class="col-sm-1 no-padding-right control-label">开设院校：</label>
                <div class="col-sm-5">
                    <form:textarea path="openSchool" cssClass="col-sm-10" rows="4"/>
                </div>
            </div><hr>
            <div class="form-group">
                <label class="col-sm-1 no-padding-right control-label">主修课程：</label>
                <div class="col-sm-4">
                    <form:textarea path="majorCourse" cssClass="col-sm-10" rows="4"/>
                </div>
                <label class="col-sm-2 no-padding-right control-label">就业前景与方向：</label>
                <div class="col-sm-5">
                    <form:textarea path="jyqjyfx" cssClass="col-sm-10" rows="4"/>
                </div>
            </div>
            <div class="form-actions">
                <shiro:hasPermission name="school:majorInfo:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="保 存"/>&nbsp;</shiro:hasPermission>
                <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
            </div>
        </form:form>
    </div>
</div>
<script src="${ctxStatic}/bootstrap/plugins/chose/chosen.jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#majorName").focus();
        $(".chosen-select").chosen();
        //选取相近专业
        $("#majorCloseCodes").change(function(){
            var closeName = "";
            $("#majorCloseCodes").find("option:selected").each(function(i,obj){
                closeName = closeName + $(obj).text()+",";
            });
            $("#majorCloseNames").val(closeName);
        });
        $("#btnSubmit").click(function(){
            if($("#inputForm").valid()){
                var url = "${ctx}/school/majorInfo/save";
                $.post(url,$("#inputForm").serialize(),function(data){
                    if(data.success){
                        showNote("success",function(){
                            window.location.href = "${ctx}/school/majorInfo/list";
                        },data.msg,"center");
                    }else{
                        showNote("error",function(){return false;},data.msg,"center");
                    }
                });
            }else{
                showNote("error",function(){return false;},"输入有误，请正确输入数据","center");
            }
        });
    });
</script>
</body>
</html>